package itheima.com.mythreadpool;

import java.util.concurrent.*;

public class MyThreadPoolDemo5 {
    public static void main(String[] args) {
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                1,
                2,
                1,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardPolicy());//丢弃任务，但不抛出异常，不推荐
        for (int i = 1; i <= 10; i++) {
            int y = i;      //记载线程执行状态
            pool.submit(() -> {
                System.out.println(Thread.currentThread().getName() + "-----" + y);
            });
        }
        pool.shutdown();
    }
}
